package com.bana.fvs.app.mvp.presenter;

import android.app.Activity;

import com.bana.fvs.app.main.entity.UserInfoBean;
import com.bana.fvs.app.mvp.contract.LoginContract;
import com.bana.fvs.app.mvp.model.LoginModel;
import com.wei.commonlibrary.net.CommException;
import com.wei.commonlibrary.net.MyDefaultCallback;

/**
 * Created by wei on 2018/2/26.
 */

public class LoginPresenter extends LoginContract.AbsLoginPresenter {
    @Override
    public void http_login(Activity activity, String username, String password) {
        mModel.http_login(username, password).callback(new MyDefaultCallback<UserInfoBean>(activity, true) {
            @Override
            public void onError(CommException e) {
                if (null != getView())
                    getView().onError(e);
            }

            @Override
            public void response(UserInfoBean user) {
                if (null != getView())
                    getView().onResponse(user);
            }
        });
    }

    @Override
    protected LoginContract.AbsLoginModel createModel() {
        return new LoginModel();
    }
}
